from elasticsearch import Elasticsearch
aa = {
    "user_activity": {
        "mappings": {
            "text": {
                "properties": {
                    "doc": {
                        "properties": {
                            "ip": {
                                "type": "string"
                            },
                            "location": {
                                "type": "string"
                            },
                            "sensitive_ip": {
                                "type": "string"
                            },
                            "sensitive_location": {
                                "type": "string"
                            },
                            "timestamp": {
                                "type": "long"
                            },
                            "uid": {
                                "type": "string"
                            }
                        }
                    },
                    "ip": {
                        "type": "string"
                    },
                    "location": {
                        "type": "string"
                    },
                    "negtive": {
                        "type": "long"
                    },
                    "nuetral": {
                        "type": "long"
                    },
                    "positive": {
                        "type": "long"
                    },
                    "sensitive_ip": {
                        "type": "string"
                    },
                    "sensitive_location": {
                        "type": "string"
                    },
                    "timestamp": {
                        "type": "long"
                    },
                    "uid": {
                        "type": "string"
                    }
                }
            }
        }
    },
    "group_information": {
        "mappings": {
            "text": {
                "properties": {
                    "aggs": {
                        "type": "object"
                    },
                    "create_condition": {
                        "properties": {
                            "agreeableness_index": {
                                "type": "long"
                            },
                            "compactness_index": {
                                "type": "long"
                            },
                            "conscientiousness_index": {
                                "type": "long"
                            },
                            "event": {
                                "type": "string"
                            },
                            "extroversion_index": {
                                "type": "long"
                            },
                            "importance_index": {
                                "type": "long"
                            },
                            "liveness_index": {
                                "type": "long"
                            },
                            "machiavellianism_index": {
                                "type": "long"
                            },
                            "narcissism_index": {
                                "type": "long"
                            },
                            "nervousness_index": {
                                "type": "long"
                            },
                            "openn_index": {
                                "type": "long"
                            },
                            "psychopathy_index": {
                                "type": "long"
                            },
                            "sensitive_index": {
                                "type": "long"
                            }
                        }
                    },
                    "create_time": {
                        "type": "long"
                    },
                    "from": {
                        "type": "long"
                    },
                    "group_id": {
                        "type": "string"
                    },
                    "group_name": {
                        "type": "string",
                        "analyzer": "caseSensitive"
                    },
                    "group_pinyin": {
                        "type": "string"
                    },
                    "query": {
                        "properties": {
                            "bool": {
                                "properties": {
                                    "must": {
                                        "properties": {
                                            "term": {
                                                "properties": {
                                                    "group_id": {
                                                        "type": "string"
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "remark": {
                        "type": "string",
                        "analyzer": "caseSensitive"
                    },
                    "size": {
                        "type": "long"
                    },
                    "state": {
                        "type": "string"
                    },
                    "user_lst": {
                        "type": "string"
                    }
                }
            }
        }
    },
    "group_activity": {
        "mappings": {
            "test1": {
                "properties": {
                    "activity_direction": {
                        "properties": {
                            "count": {
                                "type": "long"
                            },
                            "geo2geo": {
                                "type": "string"
                            }
                        }
                    },
                    "group_id": {
                        "type": "string"
                    },
                    "main_end_geo": {
                        "properties": {
                            "count": {
                                "type": "long"
                            },
                            "main_end_geo": {
                                "type": "string"
                            }
                        }
                    },
                    "main_start_geo": {
                        "properties": {
                            "count": {
                                "type": "long"
                            },
                            "main_start_geo": {
                                "type": "string"
                            }
                        }
                    },
                    "timestamp": {
                        "type": "long"
                    }
                }
            },
            "text": {
                "properties": {
                    "activity_direction": {
                        "properties": {
                            "count": {
                                "type": "long"
                            },
                            "geo2geo": {
                                "type": "string",
                                "index": "not_analyzed"
                            }
                        }
                    },
                    "group_id": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "main_end_geo": {
                        "properties": {
                            "count": {
                                "type": "long"
                            },
                            "main_end_geo": {
                                "type": "string",
                                "index": "not_analyzed"
                            }
                        }
                    },
                    "main_start_geo": {
                        "properties": {
                            "count": {
                                "type": "long"
                            },
                            "main_start_geo": {
                                "type": "string",
                                "index": "not_analyzed"
                            }
                        }
                    },
                    "timestamp": {
                        "type": "long"
                    }
                }
            }
        }
    },
    "group_emotion": {
        "mappings": {
            "text": {
                "properties": {
                    "group_id": {
                        "type": "string"
                    },
                    "negtive": {
                        "type": "long"
                    },
                    "nuetral": {
                        "type": "long"
                    },
                    "positive": {
                        "type": "long"
                    },
                    "timestamp": {
                        "type": "long"
                    }
                }
            }
        }
    },
    "user_information_1": {
        "mappings": {
            "text": {
                "_id": {
                    "path": "uid"
                },
                "properties": {
                    "age": {
                        "type": "long"
                    },
                    "attention_num": {
                        "type": "long"
                    },
                    "belong_home": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "fans_num": {
                        "type": "long"
                    },
                    "gender": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "identity": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "introduction_of_label": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "life_status": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "occupation_pre": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "political_bias": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "relationship_status": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "religion": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "timestamp": {
                        "type": "long"
                    },
                    "uid": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "username": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "weibo_num": {
                        "type": "long"
                    }
                }
            }
        }
    },
    "group_preference": {
        "mappings": {
            "text": {
                "properties": {
                    "domain": {
                        "properties": {
                            "医生": {
                                "type": "double"
                            },
                            "学生": {
                                "type": "double"
                            },
                            "工人": {
                                "type": "double"
                            }
                        }
                    },
                    "group_id": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "key_words": {
                        "properties": {
                            "健康": {
                                "type": "long"
                            },
                            "学习": {
                                "type": "long"
                            },
                            "身体": {
                                "type": "long"
                            }
                        }
                    },
                    "micro_words": {
                        "properties": {
                            "养生": {
                                "type": "long"
                            },
                            "吐槽": {
                                "type": "long"
                            },
                            "工作": {
                                "type": "long"
                            }
                        }
                    },
                    "sensitive_words": {
                        "properties": {
                            "共产党": {
                                "type": "long"
                            },
                            "反动": {
                                "type": "long"
                            },
                            "暴恐": {
                                "type": "long"
                            }
                        }
                    },
                    "timestamp": {
                        "type": "date",
                        "format": "dateOptionalTime"
                    },
                    "topic": {
                        "properties": {
                            "0": {
                                "type": "long"
                            },
                            "1": {
                                "type": "long"
                            },
                            "2": {
                                "type": "long"
                            },
                            "3": {
                                "type": "long"
                            },
                            "4": {
                                "type": "long"
                            }
                        }
                    }
                }
            }
        }
    },
    "group_influence": {
        "mappings": {
            "text": {
                "properties": {
                    "activity": {
                        "type": "double"
                    },
                    "group_id": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "influence": {
                        "type": "double"
                    },
                    "sensitivity": {
                        "type": "double"
                    },
                    "timestamp": {
                        "type": "date",
                        "format": "dateOptionalTime"
                    },
                    "warning": {
                        "type": "boolean"
                    }
                }
            }
        }
    },
    "user_social_contact": {
        "mappings": {
            "text": {
                "properties": {
                    "link": {
                        "properties": {
                            "source": {
                                "type": "string",
                                "index": "not_analyzed"
                            },
                            "target": {
                                "type": "string",
                                "index": "not_analyzed"
                            }
                        }
                    },
                    "map_type": {
                        "type": "long"
                    },
                    "node": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "uid": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "username": {
                        "type": "string",
                        "analyzer": "ik_max_word"
                    }
                }
            }
        }
    },
    "user_emotion": {
        "mappings": {
            "text": {
                "properties": {
                    "negtive": {
                        "type": "long"
                    },
                    "nuetral": {
                        "type": "long"
                    },
                    "positive": {
                        "type": "long"
                    },
                    "timestamp": {
                        "type": "long"
                    },
                    "uid": {
                        "type": "string"
                    }
                }
            }
        }
    },
    "user_information": {
        "mappings": {
            "text": {
                "_id": {
                    "path": "uid"
                },
                "properties": {
                    "age": {
                        "type": "long"
                    },
                    "attention_num": {
                        "type": "long"
                    },
                    "belong_home": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "fans_num": {
                        "type": "long"
                    },
                    "gender": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "identity": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "introduction_of_label": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "life_status": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "occupation_pre": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "political_bias": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "relationship_status": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "religion": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "timestamp": {
                        "type": "long"
                    },
                    "uid": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "username": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "weibo_num": {
                        "type": "long"
                    }
                }
            }
        }
    },
    "group_ranking": {
        "mappings": {
            "text": {
                "properties": {
                    "agreeableness_index": {
                        "type": "long"
                    },
                    "compactness_index": {
                        "type": "long"
                    },
                    "conscientiousness_index": {
                        "type": "long"
                    },
                    "extroversion_index": {
                        "type": "long"
                    },
                    "group_id": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "group_name": {
                        "type": "string",
                        "analyzer": "ik_max_word"
                    },
                    "importance_index": {
                        "type": "long"
                    },
                    "influence_index": {
                        "type": "long"
                    },
                    "liveness_index": {
                        "type": "long"
                    },
                    "machiavellianism_index": {
                        "type": "long"
                    },
                    "narcissism_index": {
                        "type": "long"
                    },
                    "nervousness_index": {
                        "type": "long"
                    },
                    "openn_index": {
                        "type": "long"
                    },
                    "psychopathy_index": {
                        "type": "long"
                    },
                    "sensitive_index": {
                        "type": "long"
                    }
                }
            }
        }
    },
    "group_social_contact": {
        "mappings": {
            "text": {
                "properties": {
                    "group_id": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "group_name": {
                        "type": "string",
                        "analyzer": "ik_max_word"
                    },
                    "link": {
                        "properties": {
                            "source": {
                                "type": "string",
                                "index": "not_analyzed"
                            },
                            "target": {
                                "type": "string",
                                "index": "not_analyzed"
                            }
                        }
                    },
                    "map_type": {
                        "type": "long"
                    },
                    "node": {
                        "type": "string",
                        "index": "not_analyzed"
                    }
                }
            }
        }
    },
    "user_influence": {
        "mappings": {
            "text": {
                "properties": {
                    "activity": {
                        "type": "long"
                    },
                    "influence": {
                        "type": "long"
                    },
                    "sensitivity": {
                        "type": "long"
                    },
                    "timestamp": {
                        "type": "long"
                    },
                    "uid": {
                        "type": "string"
                    },
                    "warning": {
                        "type": "long"
                    }
                }
            }
        }
    },
    "user_ranking": {
        "mappings": {
            "text": {
                "_id": {
                    "path": "uid"
                },
                "properties": {
                    "agreeableness_index": {
                        "type": "long"
                    },
                    "compactness_index": {
                        "type": "long"
                    },
                    "conscientiousness_index": {
                        "type": "long"
                    },
                    "extroversion_index": {
                        "type": "long"
                    },
                    "importance_index": {
                        "type": "long"
                    },
                    "influence_index": {
                        "type": "long"
                    },
                    "liveness_index": {
                        "type": "long"
                    },
                    "machiavellianism_index": {
                        "type": "long"
                    },
                    "narcissism_index": {
                        "type": "long"
                    },
                    "nervousness_index": {
                        "type": "long"
                    },
                    "openn_index": {
                        "type": "long"
                    },
                    "psychopathy_index": {
                        "type": "long"
                    },
                    "sensitive_index": {
                        "type": "long"
                    },
                    "uid": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "username": {
                        "type": "string",
                        "analyzer": "caseSensitive"
                    }
                }
            }
        }
    },
    "user_preference": {
        "mappings": {
            "text": {
                "properties": {
                    "domain": {
                        "properties": {
                            "1": {
                                "type": "string"
                            },
                            "2": {
                                "type": "string"
                            },
                            "3": {
                                "type": "string"
                            }
                        }
                    },
                    "key_words": {
                        "properties": {
                            "哈士奇": {
                                "type": "long"
                            },
                            "美女": {
                                "type": "long"
                            },
                            "购物": {
                                "type": "long"
                            }
                        }
                    },
                    "main_domain": {
                        "type": "string"
                    },
                    "micro_words": {
                        "properties": {
                            "体育": {
                                "type": "long"
                            },
                            "宠物": {
                                "type": "long"
                            },
                            "明星": {
                                "type": "long"
                            }
                        }
                    },
                    "sensitive_words": {
                        "properties": {
                            "台湾大选": {
                                "type": "long"
                            },
                            "港独": {
                                "type": "long"
                            }
                        }
                    },
                    "timestamp": {
                        "type": "long"
                    },
                    "topic": {
                        "properties": {
                            "0": {
                                "type": "long"
                            },
                            "1": {
                                "type": "long"
                            },
                            "2": {
                                "type": "long"
                            },
                            "3": {
                                "type": "long"
                            },
                            "4": {
                                "type": "long"
                            }
                        }
                    },
                    "uid": {
                        "type": "string"
                    }
                }
            }
        }
    }
}
index_info = {
    "settings": {
        "analysis": {
            "analyzer": {
                "my_analyzer": {
                    "type": "pattern",
                    "pattern": "&"  # 自定义分析器，用&作为分词的间隔
                },
                "caseSensitive": {
                    "filter": "lowercase",
                    "type": "custom",
                    "tokenizer": "keyword"
                }
            }
        },
        "number_of_replicas": 1,
        "number_of_shards": 3,
    }
}
es = Elasticsearch(['219.224.134.220:9200'])
for k, v in aa.items():
    index_info['mappings'] = aa[k]['mappings']
    es.indices.create(index=k, body=index_info)
